var MyInfo = function(){
	var updateInfoValidator = null;
	var changePasswValidator = null;
	return {
		infoViewInit:function(){
			updateInfoValidator = $("#myInfoFormEdit").validate({
				rules:{
					name:{required: true},
					userEmail:{required: true,email:true},
					userTel:{required: true,telephoneCN:true}
				}
			});
		},
		changePwdInit:function(){
			changePasswValidator = $("#paswChange").validate({
				rules:{
					oldPassword:{required:true},
					newPassword:{required: true,notSpecial:true},
					newPasswordAgain:{required: true,notSpecial:true,equalTo:"#newPassword"}
				}
			});
		},
		saveMyInfo:function(){
//			$("#myInfoFormEdit").hide();
//			$("#myInfoForm").show();
			updateInfoValidator.form();
			if (!updateInfoValidator.valid()) {
				return false;
			}
			var myChangeInfo = dwr.util.getFormValues("myInfoFormEdit");
			SysUserController.changeMyInfo(myChangeInfo,function(data){
				if(data == "success"){
					Message.success("更改成功");
				}else{
					Message.error("更改失败，请刷新页面后重试。");
				}
				
			})
			
		},
		saveChangePassword:function(){
			changePasswValidator.form();
			if (!changePasswValidator.valid()) {
				return false;
			}
			var changePassw = dwr.util.getFormValues("paswChange");
			SysUserController.changeMyPassword(changePassw.oldPassword,changePassw.newPassword,function(data){
				if(data=="更改成功"){
					Message.success(data);
					Message.close(index);
				}else{
					Message.error(data);
				}
				
			});
		}
	}
}();